package com.ayoka.parenting.ui.coach.applycoach;

import com.ayoka.parenting.Constants;
import com.ayoka.parenting.bean.ApplyCoachConditionBean;
import com.ayoka.parenting.bean.BaseResponse;
import com.ayoka.parenting.bean.SpinnerOptionBean;
import com.ayoka.parenting.http.API;
import com.ayoka.parenting.http.HttpBeanInterceptCallback;
import com.ayoka.parenting.interf.CallbackUtil;
import com.ayoka.parenting.interf.RequestCallback;
import com.ayoka.parenting.mvp.BasePresenter;

import java.util.ArrayList;
import java.util.List;

/**
 * @ProjectName: MVPPlugin.
 * @ClassName: ApplyCoachModel&.
 * @Description: .
 * @Author: jincp.
 * @CreateDate: 2019/10/10 18:17.
 */
public class ApplyCoachModel implements ApplyCoachContract.Model{


    @Override
    public List<SpinnerOptionBean> getApplyTypeOptionData() {
        List<SpinnerOptionBean> result = new ArrayList<>();
        result.add(new SpinnerOptionBean("哈巴教练", 1));
        result.add(new SpinnerOptionBean("申请类型", -1));
        return result;
    }

    @Override
    public List<SpinnerOptionBean> getDegreeOptionData() {
        List<SpinnerOptionBean> result = new ArrayList<>();
        result.add(new SpinnerOptionBean("大专", 1));
        result.add(new SpinnerOptionBean("本科", 2));
        result.add(new SpinnerOptionBean("硕士及以上", 3));
        result.add(new SpinnerOptionBean("其他", 4));
        result.add(new SpinnerOptionBean("学历", -1));
        return result;
    }

    @Override
    public List<SpinnerOptionBean> getParentOptionData() {
        List<SpinnerOptionBean> result = new ArrayList<>();
        result.add(new SpinnerOptionBean("爸爸", 1));
        result.add(new SpinnerOptionBean("妈妈", 2));
        result.add(new SpinnerOptionBean("其他亲属", 3));
        result.add(new SpinnerOptionBean("你现在的身份是", -1));
        return result;
    }


    @Override
    public List<SpinnerOptionBean> getChildrenOptionData() {
        List<SpinnerOptionBean> result = new ArrayList<>();
        result.add(new SpinnerOptionBean("1个", 1));
        result.add(new SpinnerOptionBean("2个", 2));
        result.add(new SpinnerOptionBean("3个及以上", 3));
        result.add(new SpinnerOptionBean("几个孩子", -1));
        return result;
    }

    @Override
    public List<SpinnerOptionBean> getCompleteOptionData() {
        List<SpinnerOptionBean> result = new ArrayList<>();
        result.add(new SpinnerOptionBean("否", 0));
        result.add(new SpinnerOptionBean("是", 1));
        result.add(new SpinnerOptionBean("是否完成21天冥想", -1));
        return result;
    }

    @Override
    public void submitApplyCoach(final BasePresenter presenter, final String name, final int applyType, final String birthDate, final int degree, final String province, String city, final String work, final String contractMobile, final String email, final String contractAddress, final int parent, final int children, final String wechatNumber, final int complete, final String experience, final String extra, final RequestCallback<ApplyCoachConditionBean> callback) {
        API.submitApplyCoach(presenter, name, applyType, birthDate, degree, province, city, work, contractMobile, email, contractAddress, parent, children, wechatNumber, complete, experience, extra, new HttpBeanInterceptCallback<BaseResponse<ApplyCoachConditionBean>>() {
            @Override
            public void onSuccess(BaseResponse<ApplyCoachConditionBean> response) {
                CallbackUtil.notifySuccess(callback, response.data);
            }

            @Override
            public void onFailure(int errorCode, String errorMessage) {
                if (errorCode == Constants.WX_ERROR_TOKEN) {
                    submitApplyCoach(presenter, name, applyType, birthDate, degree, province, province, work, contractMobile, email, contractAddress, parent, children, wechatNumber, complete, experience, extra, callback);
                    return;
                }
                CallbackUtil.notifyFailure(callback, errorCode, errorMessage);
            }
        });
    }
}
